package com.erbao.thread;

/**
 * @author CaoBaoYin
 * @since 2022/1/2 16:04
 */
public class TreadInterrupted {
    public static void main(String[] args) {
        Thread t = new Thread(() -> {
            for (; ; ) {
                if (Thread.interrupted()) {
                    System.out.println("Thread is interrupted!");
                    System.out.println(Thread.interrupted());
                }
            }
        });

        t.start();

        SleepHelper.sleepSeconds(2);

        t.interrupt();

        //思考一下，如果在这里写
        System.out.println("main: " + t.interrupted());
        //输出的是当前线程的中断状态
    }

}
